#!/user/bin/env node

const Router = require('koa-router'),
	appointment = require('../models/appointment_mod.js'),
	router = new Router,
	sj = require('silly-datetime');
router.prefix('/api/appointment');

router.post('/', async (ctx, next) => {
	let { user_id } = ctx.request.body;
	let res = await appointment.Getlist(user_id);
	ctx.body = res;
})
router.post('/2', async (ctx, next) => {
        let { commodity_id } = ctx.request.body;
        let res = await appointment.Getlist2(commodity_id);
        ctx.body = res;
})
router.put('/', async (ctx, next) => {
	let { user_id, commodity_id ,time} = ctx.request.body;
	console.log(user_id,commodity_id,time);
	let res = await appointment.Insert_appo(user_id, commodity_id,time);
	ctx.body = res;
})

router.delete('/', async (ctx, next) => {
	let { user_id, commodity_id } = ctx.request.body;
	let res = await appointment.Delete_appo(user_id, commodity_id);
	ctx.body = res;
})
module.exports = router;

